import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
var _excluded = ["strategyParam"];

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _class, _class2;

/**
 * jobInfo - 调度任务
 * @date: 2018-9-7

 */
import React from 'react';
import { connect } from 'dva';
import { Bind } from 'lodash-decorators';
import { Form, Popconfirm, Table, Tooltip, Tag } from 'antd';
import { Content, Header } from 'components/Page';
import cacheComponent from 'components/CacheComponent';
import { Button as ButtonPermission } from 'components/Permission';
import notification from 'utils/notification';
import intl from 'utils/intl';
import formatterCollections from 'utils/intl/formatterCollections';
import { getCurrentOrganizationId, isTenantRoleLevel, tableScrollWidth } from 'utils/utils';
import { TagRender, yesOrNoRender, operatorRender } from 'utils/renderer';
import Drawer from "./Drawer";
import LogDrawer from "./LogDrawer";
import LogErrorDrawer from "./LogErrorDrawer";
import FilterForm from "./FilterForm";
import LogModal from "./LogModal";
var JobInfo = (_dec = connect(function (_ref) {
  var loading = _ref.loading,
      jobInfo = _ref.jobInfo,
      jobLog = _ref.jobLog;
  return {
    jobInfo: jobInfo,
    jobLog: jobLog,
    fetchList: loading.effects['jobInfo/fetchJobInfo'],
    creating: loading.effects['jobInfo/createJobInfo'],
    updating: loading.effects['jobInfo/updateJobInfo'],
    fetchJobError: loading.effects['jobInfo/fetchJobLogError'],
    fetchJogLoading: loading.effects['jobInfo/fetchJobLog'],
    detailLoading: loading.effects['jobInfo/queryJobInfo'],
    logDetailLoading: loading.effects['jobLog/fetchLogDetail'],
    checkLoading: loading.effects['jobInfo/checkJobInfo'],
    configLoading: loading.effects['jobInfo/executorConfig'],
    deleteLoading: loading.effects['jobInfo/deleteJobInfo'],
    copyLoading: loading.effects['jobInfo/copyJobInfo'],
    tenantId: getCurrentOrganizationId(),
    tenantRoleLevel: isTenantRoleLevel()
  };
}), _dec2 = Form.create({
  fieldNameProp: null
}), _dec3 = formatterCollections({
  code: ['csdr.jobInfo', 'csdr.jobLog']
}), _dec4 = cacheComponent({
  cacheKey: '/csdr/job-info/list'
}), _dec5 = Bind(), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), _dec11 = Bind(), _dec12 = Bind(), _dec13 = Bind(), _dec14 = Bind(), _dec15 = Bind(), _dec16 = Bind(), _dec17 = Bind(), _dec18 = Bind(), _dec19 = Bind(), _dec20 = Bind(), _dec21 = Bind(), _dec22 = Bind(), _dec23 = Bind(), _dec24 = Bind(), _dec25 = Bind(), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = (_class2 = /*#__PURE__*/function (_React$PureComponent) {
  _inherits(JobInfo, _React$PureComponent);

  var _super = _createSuper(JobInfo);

  function JobInfo() {
    var _this;

    _classCallCheck(this, JobInfo);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    _this.form = void 0;
    _this.state = {
      jobModalVisible: false,
      jobErrorModalVisible: false,
      jobLogId: '',
      selectedRowKeys: [],
      selectRows: [],
      logVisible: false,
      logDetail: ''
    };
    return _this;
  }

  _createClass(JobInfo, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var dispatch = this.props.dispatch;
      this.fetchJobInfo();
      dispatch({
        type: 'jobInfo/init'
      });
    }
  }, {
    key: "queryGroups",
    value: function queryGroups() {
      var dispatch = this.props.dispatch;
      dispatch({
        type: 'jobInfo/fetchGroupsList'
      });
    }
    /**
     * @function fetchJobInfo - 获取列表数据
     * @param {object} params - 查询参数
     * @param {number} params.page - 页码
     * @param {number} params.size - 页数
     */

  }, {
    key: "fetchJobInfo",
    value: function fetchJobInfo() {
      var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var _this$props = this.props,
          dispatch = _this$props.dispatch,
          _this$props$jobInfo$p = _this$props.jobInfo.pagination,
          pagination = _this$props$jobInfo$p === void 0 ? {} : _this$props$jobInfo$p;
      var filterValue = this.form === undefined ? {} : this.form.getFieldsValue();
      dispatch({
        type: 'jobInfo/fetchJobInfo',
        payload: _objectSpread(_objectSpread({
          page: pagination
        }, filterValue), params)
      });
    }
  }, {
    key: "fetchJobDetail",
    value: function fetchJobDetail() {
      var _this2 = this;

      var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var dispatch = this.props.dispatch;
      dispatch({
        type: 'jobInfo/queryJobInfo',
        payload: {
          id: params.jobId
        }
      }).then(function (res) {
        if (res) {
          if (res.executorStrategy === 'JOB_WEIGHT') {
            _this2.handleConfig(res);
          }
        }
      });
    }
    /**
     * @function handleSearch - 搜索表单
     */

  }, {
    key: "handleSearch",
    value: function handleSearch() {
      this.fetchJobInfo({
        page: {}
      });
    }
    /**
     * 获取查询表单组件this对象
     * @param {object} ref - 查询表单组件this
     */

  }, {
    key: "handleBindRef",
    value: function handleBindRef(ref) {
      this.form = (ref.props || {}).form;
    }
    /**
     * @function handleModalVisible - 控制modal显示与隐藏
     * @param {boolean} flag 是否显示modal
     */

  }, {
    key: "handleModalVisible",
    value: function handleModalVisible(flag) {
      var dispatch = this.props.dispatch;
      dispatch({
        type: 'jobInfo/updateState',
        payload: {
          modalVisible: !!flag
        }
      }); // 清空执行器配置列表

      if (!flag) {
        dispatch({
          type: 'jobInfo/updateState',
          payload: {
            executorConfigList: []
          }
        });
      }
    }
    /**
     * @function showCreateModal - 显示新增modal
     */

  }, {
    key: "showCreateModal",
    value: function showCreateModal() {
      var dispatch = this.props.dispatch;
      dispatch({
        type: 'jobInfo/updateState',
        payload: {
          jobInfoDetail: {}
        }
      });
      this.handleModalVisible(true);
    }
    /**
     * 检查执行器
     * @param {string} executorId - 执行器ID
     */

  }, {
    key: "handleCheck",
    value: function handleCheck(executorId) {
      var dispatch = this.props.dispatch;
      dispatch({
        type: 'jobInfo/checkJobInfo',
        payload: {
          executorId: executorId
        }
      }).then(function (res) {
        if (res) {
          notification.success();
        }
      });
    }
  }, {
    key: "handleAdd",
    value: function handleAdd(fieldsValue) {
      var _this3 = this;

      var _this$props2 = this.props,
          dispatch = _this$props2.dispatch,
          _this$props2$jobInfo$ = _this$props2.jobInfo.jobInfoDetail,
          jobInfoDetail = _this$props2$jobInfo$ === void 0 ? {} : _this$props2$jobInfo$;
      var jobId = jobInfoDetail.jobId;

      var strategyParam = fieldsValue.strategyParam,
          others = _objectWithoutProperties(fieldsValue, _excluded);

      dispatch({
        type: "jobInfo/".concat(jobId ? 'updateJobInfo' : 'createJobInfo'),
        payload: _objectSpread(_objectSpread(_objectSpread({}, jobInfoDetail), others), {}, {
          strategyParam: JSON.stringify(fieldsValue.strategyParam)
        })
      }).then(function (res) {
        if (res) {
          notification.success();

          _this3.handleModalVisible(false);

          _this3.fetchJobInfo();
        }
      });
    }
    /**
     * 获取执行器列表
     * @param {object} data 选择的执行器策略数据
     */

  }, {
    key: "handleConfig",
    value: function handleConfig(data) {
      var dispatch = this.props.dispatch;

      if (data) {
        dispatch({
          type: 'jobInfo/executorConfigByJob',
          payload: {
            jobId: data.jobId,
            executorId: data.executorId
          }
        }).then(function (res) {
          if (res) {
            var arr = [];
            Object.keys(res).forEach(function (item) {
              arr.push({
                address: item,
                weight: res[item]
              });
            });
            dispatch({
              type: 'jobInfo/updateState',
              payload: {
                executorConfigList: arr
              }
            });
          }
        });
      } else {
        dispatch({
          type: 'jobInfo/updateState',
          payload: {
            executorConfigList: []
          }
        });
      }
    }
    /**
     * @function handleEditJob- 操作job
     * @param {object} record - 行数据
     * @param {string} type - 操作任务的类型
     */

  }, {
    key: "handleEditJob",
    value: function handleEditJob(record, type) {
      var _this4 = this;

      var dispatch = this.props.dispatch;
      dispatch({
        type: "jobInfo/".concat(type),
        payload: record
      }).then(function (res) {
        if (res) {
          notification.success();

          _this4.fetchJobInfo();
        }
      });
    }
    /**
     * @function handleEditJob- 删除job
     */

  }, {
    key: "handleDelete",
    value: function handleDelete() {
      var _this5 = this;

      var dispatch = this.props.dispatch;
      var selectRows = this.state.selectRows;
      dispatch({
        type: 'jobInfo/deleteJobInfo',
        payload: selectRows
      }).then(function (res) {
        if (res) {
          notification.success();

          _this5.fetchJobInfo();

          _this5.setState({
            selectRows: [],
            selectedRowKeys: []
          });
        }
      });
    }
    /**
     * @function handleUpdateEmail - 编辑
     * @param {object} record - 行数据
     */

  }, {
    key: "handleUpdate",
    value: function handleUpdate(record) {
      this.fetchJobDetail(record);
      this.handleModalVisible(true);
    }
  }, {
    key: "handleCopy",
    value: function handleCopy(record) {
      var dispatch = this.props.dispatch;
      this.showCreateModal();
      dispatch({
        type: 'jobInfo/copyJobInfo',
        payload: {
          jobId: record.jobId
        }
      }).then(function (res) {
        if (res) {
          dispatch({
            type: 'jobInfo/updateState',
            payload: {
              jobInfoDetail: res
            }
          });
        }
      });
    }
    /**
     * @function handlePagination - 分页操作
     */

  }, {
    key: "handlePagination",
    value: function handlePagination(pagination) {
      this.fetchJobInfo({
        page: pagination
      });
    }
  }, {
    key: "hideJobLogErrorDrawer",
    value: function hideJobLogErrorDrawer() {
      this.setState({
        jobErrorModalVisible: false
      });
    }
  }, {
    key: "handleJobError",
    value: function handleJobError(data) {
      var dispatch = this.props.dispatch;
      this.setState({
        jobErrorModalVisible: true
      });
      dispatch({
        type: 'jobInfo/fetchJobLogError',
        payload: data
      });
    }
  }, {
    key: "handleDeleteJobLog",
    value: function handleDeleteJobLog(record) {
      var _this6 = this;

      var _this$props3 = this.props,
          dispatch = _this$props3.dispatch,
          _this$props3$jobInfo$ = _this$props3.jobInfo.jobPagination,
          jobPagination = _this$props3$jobInfo$ === void 0 ? {} : _this$props3$jobInfo$;
      dispatch({
        type: 'jobInfo/deleteJobLog',
        payload: {
          logId: record.logId,
          jobId: record.jobId,
          _token: record._token
        }
      }).then(function (res) {
        if (res) {
          notification.success();

          _this6.fetchJobLog({
            page: jobPagination.current - 1,
            size: jobPagination.pageSize
          });
        }
      });
    }
  }, {
    key: "showJobDrawer",
    value: function showJobDrawer(flag) {
      this.setState({
        jobModalVisible: flag
      });
    }
  }, {
    key: "hideJobLogDrawer",
    value: function hideJobLogDrawer() {
      this.showJobDrawer(false);
    }
  }, {
    key: "fetchJobLog",
    value: function fetchJobLog() {
      var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var dispatch = this.props.dispatch;
      var jobLogId = this.state.jobLogId;
      return dispatch({
        type: 'jobInfo/fetchJobLog',
        payload: _objectSpread({
          jobId: jobLogId
        }, params)
      });
    }
    /**
     * 跳转到日志页面
     * @param {object} params - 头数据
     */

  }, {
    key: "handleLogContent",
    value: function handleLogContent(params) {
      var dispatch = this.props.dispatch;
      dispatch({
        type: 'jobInfo/updateState',
        payload: {
          jobLogList: [],
          jobPagination: {}
        }
      });
      this.setState({
        jobLogId: params.jobId
      });
      this.showJobDrawer(true);
      this.fetchJobLog(params);
    }
  }, {
    key: "handleSelectTable",
    value: function handleSelectTable(keys, rows) {
      this.setState({
        selectedRowKeys: keys,
        selectRows: rows
      });
    }
  }, {
    key: "handleFetchLogDetail",
    value: function handleFetchLogDetail(record) {
      var _this7 = this;

      var dispatch = this.props.dispatch;
      this.setState({
        logVisible: true
      }, function () {
        dispatch({
          type: 'jobLog/fetchLogDetail',
          payload: {
            logId: record.logId
          }
        }).then(function (res) {
          if (res) {
            _this7.setState({
              logDetail: res
            });
          }
        });
      });
    }
  }, {
    key: "closeLogDetailModal",
    value: function closeLogDetailModal() {
      this.setState({
        logVisible: false,
        logDetail: ''
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this8 = this;

      var _this$props4 = this.props,
          updating = _this$props4.updating,
          creating = _this$props4.creating,
          fetchList = _this$props4.fetchList,
          tenantId = _this$props4.tenantId,
          tenantRoleLevel = _this$props4.tenantRoleLevel,
          path = _this$props4.match.path,
          _this$props4$fetchJog = _this$props4.fetchJogLoading,
          fetchJogLoading = _this$props4$fetchJog === void 0 ? false : _this$props4$fetchJog,
          _this$props4$fetchJob = _this$props4.fetchJobError,
          fetchJobError = _this$props4$fetchJob === void 0 ? false : _this$props4$fetchJob,
          _this$props4$jobInfo = _this$props4.jobInfo,
          jobInfo = _this$props4$jobInfo === void 0 ? {} : _this$props4$jobInfo,
          dispatch = _this$props4.dispatch,
          _this$props4$checkLoa = _this$props4.checkLoading,
          checkLoading = _this$props4$checkLoa === void 0 ? false : _this$props4$checkLoa,
          _this$props4$configLo = _this$props4.configLoading,
          configLoading = _this$props4$configLo === void 0 ? false : _this$props4$configLo,
          _this$props4$detailLo = _this$props4.detailLoading,
          detailLoading = _this$props4$detailLo === void 0 ? false : _this$props4$detailLo,
          _this$props4$deleteLo = _this$props4.deleteLoading,
          deleteLoading = _this$props4$deleteLo === void 0 ? false : _this$props4$deleteLo,
          _this$props4$copyLoad = _this$props4.copyLoading,
          copyLoading = _this$props4$copyLoad === void 0 ? false : _this$props4$copyLoad,
          _this$props4$logDetai = _this$props4.logDetailLoading,
          logDetailLoading = _this$props4$logDetai === void 0 ? false : _this$props4$logDetai;
      var _this$state = this.state,
          jobErrorModalVisible = _this$state.jobErrorModalVisible,
          jobModalVisible = _this$state.jobModalVisible,
          selectedRowKeys = _this$state.selectedRowKeys,
          jobLogFirstLoadedLoading = _this$state.jobLogFirstLoadedLoading,
          logVisible = _this$state.logVisible,
          logDetail = _this$state.logDetail;
      var modalVisible = jobInfo.modalVisible,
          jobInfoDetail = jobInfo.jobInfoDetail,
          _jobInfo$jobInfoList = jobInfo.jobInfoList,
          jobInfoList = _jobInfo$jobInfoList === void 0 ? [] : _jobInfo$jobInfoList,
          _jobInfo$groupsList = jobInfo.groupsList,
          groupsList = _jobInfo$groupsList === void 0 ? [] : _jobInfo$groupsList,
          _jobInfo$pagination = jobInfo.pagination,
          pagination = _jobInfo$pagination === void 0 ? {} : _jobInfo$pagination,
          _jobInfo$jobLogList = jobInfo.jobLogList,
          jobLogList = _jobInfo$jobLogList === void 0 ? [] : _jobInfo$jobLogList,
          _jobInfo$jobPaginatio = jobInfo.jobPagination,
          jobPagination = _jobInfo$jobPaginatio === void 0 ? {} : _jobInfo$jobPaginatio,
          _jobInfo$jobErrorDeta = jobInfo.jobErrorDetail,
          jobErrorDetail = _jobInfo$jobErrorDeta === void 0 ? {} : _jobInfo$jobErrorDeta,
          _jobInfo$jobLogLdp = jobInfo.jobLogLdp,
          jobLogLdp = _jobInfo$jobLogLdp === void 0 ? {} : _jobInfo$jobLogLdp,
          _jobInfo$executorConf = jobInfo.executorConfigList,
          executorConfigList = _jobInfo$executorConf === void 0 ? {} : _jobInfo$executorConf,
          _jobInfo$glueTypeList = jobInfo.glueTypeList,
          glueTypeList = _jobInfo$glueTypeList === void 0 ? [] : _jobInfo$glueTypeList,
          _jobInfo$jobStatusLis = jobInfo.jobStatusList,
          jobStatusList = _jobInfo$jobStatusLis === void 0 ? [] : _jobInfo$jobStatusLis,
          _jobInfo$sourceFlagLi = jobInfo.sourceFlagList,
          sourceFlagList = _jobInfo$sourceFlagLi === void 0 ? [] : _jobInfo$sourceFlagLi;
      var jobId = jobInfoDetail.jobId;
      var requestLoading = {
        save: updating,
        create: creating
      };
      var logDrawer = {
        tenantId: tenantId,
        dispatch: dispatch,
        jobLogLdp: jobLogLdp,
        jobLogList: jobLogList,
        jobPagination: jobPagination,
        path: path,
        title: intl.get('csdr.jobLog.view.message.title').d('调度日志'),
        initLoading: fetchJogLoading,
        loading: fetchJogLoading,
        modalVisible: jobModalVisible,
        onSearch: this.fetchJobLog,
        onCancel: this.hideJobLogDrawer,
        onError: this.handleJobError,
        onDelete: this.handleDeleteJobLog,
        jobLogFirstLoadedLoading: jobLogFirstLoadedLoading,
        onFetchLogDetail: this.handleFetchLogDetail
      };
      var logErrorProps = {
        jobErrorDetail: jobErrorDetail,
        initLoading: fetchJobError,
        modalVisible: jobErrorModalVisible,
        onOk: this.hideJobLogErrorDrawer,
        onCancel: this.hideJobLogErrorDrawer
      };
      var logDetailProps = {
        logDetail: logDetail,
        logVisible: logVisible,
        logDetailLoading: logDetailLoading,
        onOk: this.closeLogDetailModal
      };
      var rowSelection = {
        selectedRowKeys: selectedRowKeys,
        onChange: this.handleSelectTable,
        getCheckboxProps: function getCheckboxProps(record) {
          return {
            disabled: record.jobStatus !== 'NONE'
          };
        }
      };
      var columns = [{
        title: intl.get('csdr.jobInfo.model.jobInfo.id').d('任务ID'),
        width: 150,
        dataIndex: 'taskId'
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.tenantName').d('所属租户'),
        width: 150,
        dataIndex: 'tenantName'
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.jobCode').d('任务编码'),
        width: 150,
        dataIndex: 'jobCode'
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.glueType').d('任务类型'),
        width: 100,
        dataIndex: 'glueTypeMeaning'
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.jobHandler').d('JobHandler'),
        width: 120,
        dataIndex: 'jobHandler'
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.executorName').d('执行器'),
        width: 120,
        dataIndex: 'executorName'
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.sourceFlag').d('来源标识'),
        width: 120,
        dataIndex: 'sourceFlag',
        render: function render(value, record) {
          return value === 'JOB' ? /*#__PURE__*/React.createElement(Tag, {
            color: "green"
          }, record.sourceFlagMeaning) : /*#__PURE__*/React.createElement(Tag, {
            color: "blue"
          }, record.sourceFlagMeaning);
        }
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.jobDesc').d('任务描述'),
        dataIndex: 'description'
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.jobCron').d('Cron'),
        dataIndex: 'jobCron'
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.parentId').d('父任务ID'),
        dataIndex: 'parentId',
        width: 100
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.cycleFlag').d('周期性'),
        dataIndex: 'cycleFlag',
        width: 100,
        render: yesOrNoRender
      }, {
        title: intl.get('csdr.jobInfo.model.jobInfo.jobStatusMeaning').d('状态'),
        width: 100,
        fixed: 'right',
        dataIndex: 'jobStatusMeaning',
        render: function render(text, record) {
          var statusList = [{
            status: 'NORMAL',
            color: 'green'
          }, {
            status: 'PAUSED',
            color: 'gold'
          }, {
            status: 'BLOCKED',
            color: 'volcano'
          }, {
            status: 'ERROR',
            color: 'red'
          }, {
            status: 'NONE',
            color: ''
          }, {
            status: 'COMPLETE',
            color: ''
          }];
          return TagRender(record.jobStatus, statusList, text);
        }
      }, {
        title: intl.get('cpaas.common.button.action').d('操作'),
        width: 160,
        fixed: 'right',
        render: function render(text, record) {
          var operators = [];
          operators.push({
            key: 'log',
            ele: /*#__PURE__*/React.createElement(ButtonPermission, {
              type: "text",
              permissionList: [{
                code: "".concat(path, ".button.log"),
                type: 'button',
                meaning: '调度任务-日志'
              }],
              onClick: _this8.handleLogContent.bind(_this8, {
                jobId: record.jobId
              })
            }, intl.get('csdr.jobInfo.view.option.log').d('日志'), ' '),
            len: 2,
            title: intl.get('csdr.jobInfo.view.option.log').d('日志')
          });
          operators.push({
            key: 'copy',
            ele: /*#__PURE__*/React.createElement(Popconfirm, {
              title: "".concat(intl.get('csdr.jobInfo.view.message.confirm.copy').d('是否复制该任务'), "\uFF1F"),
              onConfirm: _this8.handleCopy.bind(_this8, record)
            }, /*#__PURE__*/React.createElement(ButtonPermission, {
              type: "text",
              permissionList: [{
                code: "".concat(path, ".button.copy"),
                type: 'button',
                meaning: '调度任务-复制'
              }]
            }, intl.get('cpaas.common.button.copy').d('复制'), ' '), ' '),
            len: 2,
            title: intl.get('cpaas.common.button.copy').d('复制')
          });

          if (record.jobStatus === 'NORMAL') {
            if (record.cycleFlag === 1) {
              operators.push({
                key: 'trigger',
                ele: /*#__PURE__*/React.createElement(Popconfirm, {
                  title: "".concat(intl.get('csdr.jobInfo.view.message.confirm.trigger').d('是否执行该任务'), "\uFF1F"),
                  onConfirm: _this8.handleEditJob.bind(_this8, record, 'triggerJobInfo')
                }, /*#__PURE__*/React.createElement(Tooltip, {
                  placement: "top",
                  title: intl.get('csdr.jobInfo.view.message.tooltipMsg').d('执行：手动执行任务一次')
                }, /*#__PURE__*/React.createElement(ButtonPermission, {
                  type: "text",
                  permissionList: [{
                    code: "".concat(path, ".button.trigger"),
                    type: 'button',
                    meaning: '调度任务-执行'
                  }]
                }, intl.get('cpaas.common.button.trigger').d('执行'), ' '), ' ')),
                len: 2,
                title: intl.get('cpaas.common.button.trigger').d('执行')
              });
            }

            operators.push({
              key: 'pause',
              ele: /*#__PURE__*/React.createElement(Popconfirm, {
                title: "".concat(intl.get('csdr.jobInfo.view.message.confirm.pause').d('是否暂停该任务'), "\uFF1F"),
                onConfirm: _this8.handleEditJob.bind(_this8, record, 'pauseJobInfo')
              }, /*#__PURE__*/React.createElement(ButtonPermission, {
                type: "text",
                permissionList: [{
                  code: "".concat(path, ".button.pause"),
                  type: 'button',
                  meaning: '调度任务-暂停'
                }]
              }, intl.get('cpaas.common.button.pause').d('暂停'), ' '), ' '),
              len: 2,
              title: intl.get('cpaas.common.button.pause').d('暂停')
            });
          }

          if (record.jobStatus !== 'NONE') {
            operators.push({
              key: 'stop',
              ele: /*#__PURE__*/React.createElement(Popconfirm, {
                title: "".concat(intl.get('csdr.jobInfo.view.message.confirm.stop').d('是否终止该任务'), "\uFF1F"),
                onConfirm: _this8.handleEditJob.bind(_this8, record, 'stopJob')
              }, /*#__PURE__*/React.createElement(ButtonPermission, {
                type: "text",
                permissionList: [{
                  code: "".concat(path, ".button.stop"),
                  type: 'button',
                  meaning: '调度任务-终止'
                }]
              }, intl.get('csdr.jobInfo.option.stop').d('终止'), ' '), ' '),
              len: 2,
              title: intl.get('csdr.jobInfo.option.stop').d('终止')
            });
          }

          if (record.jobStatus === 'PAUSED') {
            operators.push({
              key: 'pause',
              ele: /*#__PURE__*/React.createElement(Popconfirm, {
                title: "".concat(intl.get('csdr.notice.view.message.confirm.resume').d('是否恢复该任务'), "\uFF1F"),
                onConfirm: _this8.handleEditJob.bind(_this8, record, 'resumeJobInfo')
              }, /*#__PURE__*/React.createElement(ButtonPermission, {
                type: "text",
                permissionList: [{
                  code: "".concat(path, ".button.resume"),
                  type: 'button',
                  meaning: '调度任务-恢复'
                }]
              }, intl.get('cpaas.common.button.resume').d('恢复'), ' '), ' '),
              len: 2,
              title: intl.get('cpaas.common.button.resume').d('恢复')
            });
          }

          if (record.jobStatus !== 'PAUSED' && record.jobStatus !== 'COMPLETE' && record.jobStatus !== 'NONE') {
            operators.push({
              key: 'edit',
              ele: /*#__PURE__*/React.createElement(ButtonPermission, {
                type: "text",
                permissionList: [{
                  code: "".concat(path, ".button.edit"),
                  type: 'button',
                  meaning: '调度任务-编辑'
                }],
                onClick: _this8.handleUpdate.bind(_this8, record)
              }, intl.get('cpaas.common.button.edit').d('编辑'), ' '),
              len: 2,
              title: intl.get('cpaas.common.button.edit').d('编辑')
            });
          }

          return operatorRender(operators, record, {
            limit: 3
          });
        }
      }].filter(function (col) {
        return tenantRoleLevel ? col.dataIndex !== 'tenantName' : true;
      });
      var title = jobId ? intl.get('csdr.jobInfo.view.message.edit').d('编辑调度任务') : intl.get('csdr.jobInfo.view.message.create').d('新建调度任务');
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
        title: intl.get('csdr.jobInfo.view.message.title.list').d('调度任务')
      }, /*#__PURE__*/React.createElement(ButtonPermission, {
        icon: "plus",
        type: "primary",
        permissionList: [{
          code: "".concat(path, ".button.create"),
          type: 'button',
          meaning: '调度任务-新建'
        }],
        onClick: this.showCreateModal
      }, intl.get('cpaas.common.button.create').d('新建'), ' '), ' '), ' ', /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement("div", {
        className: "table-list-search"
      }, /*#__PURE__*/React.createElement(FilterForm, {
        onSearch: this.handleSearch,
        glueTypeList: glueTypeList,
        jobStatusList: jobStatusList,
        onRef: this.handleBindRef,
        sourceFlagList: sourceFlagList
      }), ' '), ' ', /*#__PURE__*/React.createElement("div", {
        style: {
          margin: '24px 0 16px 0',
          textAlign: 'right'
        }
      }, /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.delete"),
          type: 'button',
          meaning: '调度任务-删除'
        }],
        loading: deleteLoading,
        disabled: selectedRowKeys.length === 0,
        onClick: this.handleDelete
      }, intl.get('cpaas.common.button.delete').d('删除'), ' '), ' '), ' ', /*#__PURE__*/React.createElement(Table, {
        bordered: true,
        rowKey: "jobId",
        loading: fetchList,
        dataSource: jobInfoList,
        columns: columns,
        rowSelection: rowSelection,
        scroll: {
          x: tableScrollWidth(columns)
        },
        pagination: pagination,
        onChange: this.handlePagination
      }), ' ', /*#__PURE__*/React.createElement(Drawer, {
        title: title,
        loading: jobId ? requestLoading.save : requestLoading.create,
        detailLoading: detailLoading || copyLoading,
        checkLoading: checkLoading,
        configLoading: configLoading,
        modalVisible: modalVisible,
        onConfig: this.handleConfig,
        onCancel: function onCancel() {
          return _this8.handleModalVisible(false);
        },
        onOk: this.handleAdd,
        onCheck: this.handleCheck,
        initData: jobInfoDetail,
        jobInfo: jobInfo,
        executorConfigList: executorConfigList,
        groupsList: groupsList,
        fetchJobDetail: this.fetchJobDetail,
        tenantRoleLevel: tenantRoleLevel,
        tenantId: tenantId,
        onSearchGroup: this.queryGroups
      }), ' ', /*#__PURE__*/React.createElement(LogDrawer, logDrawer), " ", /*#__PURE__*/React.createElement(LogModal, logDetailProps), ' ', /*#__PURE__*/React.createElement(LogErrorDrawer, logErrorProps), ' '), ' ');
    }
  }]);

  return JobInfo;
}(React.PureComponent), (_applyDecoratedDescriptor(_class2.prototype, "queryGroups", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "queryGroups"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSearch", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSearch"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleBindRef", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "handleBindRef"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleModalVisible", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "handleModalVisible"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "showCreateModal", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "showCreateModal"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleCheck", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCheck"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleAdd", [_dec11], Object.getOwnPropertyDescriptor(_class2.prototype, "handleAdd"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleConfig", [_dec12], Object.getOwnPropertyDescriptor(_class2.prototype, "handleConfig"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleDelete", [_dec13], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDelete"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleUpdate", [_dec14], Object.getOwnPropertyDescriptor(_class2.prototype, "handleUpdate"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleCopy", [_dec15], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCopy"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handlePagination", [_dec16], Object.getOwnPropertyDescriptor(_class2.prototype, "handlePagination"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "hideJobLogErrorDrawer", [_dec17], Object.getOwnPropertyDescriptor(_class2.prototype, "hideJobLogErrorDrawer"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleJobError", [_dec18], Object.getOwnPropertyDescriptor(_class2.prototype, "handleJobError"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleDeleteJobLog", [_dec19], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDeleteJobLog"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "showJobDrawer", [_dec20], Object.getOwnPropertyDescriptor(_class2.prototype, "showJobDrawer"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "hideJobLogDrawer", [_dec21], Object.getOwnPropertyDescriptor(_class2.prototype, "hideJobLogDrawer"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "fetchJobLog", [_dec22], Object.getOwnPropertyDescriptor(_class2.prototype, "fetchJobLog"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSelectTable", [_dec23], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSelectTable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleFetchLogDetail", [_dec24], Object.getOwnPropertyDescriptor(_class2.prototype, "handleFetchLogDetail"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "closeLogDetailModal", [_dec25], Object.getOwnPropertyDescriptor(_class2.prototype, "closeLogDetailModal"), _class2.prototype)), _class2)) || _class) || _class) || _class) || _class);
export { JobInfo as default };